import Vue from 'vue'
import VueRouter from 'vue-router'
//import Home from '../views/Home.vue'

Vue.use(VueRouter)

//两个固定写法 防止报错的
const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(to) {
    return VueRouterPush.call(this, to).catch(err => err)
}

//replace
const VueRouterReplace = VueRouter.prototype.replace
VueRouter.prototype.replace = function replace(to) {
    return VueRouterReplace.call(this, to).catch(err => err)
}

const routes = [
    {
        path: '/',
        name: 'Main',//默认进入Main这个路由 而且Main里面都是这个项目的Uiz组件
        component: () => import('../view/Main.vue'),
        // redirect: '/home', //路由重定向 默认进入home页面 home界面其实就是main的一个子组件 你可以想成进入了/Main/home 只不过这个main在上面定义的时候定义为/ 所以就是/home
        children: [
            {
                path: '/home',
                name: 'home',
                component: () => import('../view/Home/index.vue')
            },
            {
                path: '/mall',
                name: 'mall',
                component: () => import('../view/mall')
            },
            {
                path: '/findmall',
                name: 'findmall',
                component: () => import('../view/findmall/findmall.vue')
            },
            {
                path: '/newmall',
                name: 'newmall',
                component: () => import('../view/newmall/newmall.vue')
            },
            {
                path: '/goods',
                name: 'goods',
                component: () => import('../view/goods/goods.vue')
            },
            {
                path: '/findgoods',
                name: 'findgoods',
                component: () => import('../view/addgoods/addgoods.vue')
            },
            {
                path: '/ex',
                name: 'Home',
                component: () => import('../view/Ex/Home.vue')
            },
            {
                path: 'upload',
                name: 'Upload',
                component: () => import('../view/Ex/Upload.vue')
            },
            {
                path: '/person',
                name: 'person',
                component: () => import('../view/Person/person.vue')
            },
            {
                path: '/password',
                name: 'password',
                component: () => import('../view/password/password.vue')
            },
            {
                path: '/page1',
                name: 'page1',
                component: () => import('../view/other/pageOne.vue')
            },
            {
                path: '/page2',
                name: 'page2',
                component: () => import('../view/other/pageTwo.vue')
            },
        ]

    },
    {
        path: '/login',
        name: 'login',
        component: () => import('../view/Login/login.vue')
    }


]


const router = new VueRouter({
    mode: 'hash', //模式选择 选择了hash模式
    routes
})

export default router